<template>
  <div class="chat-app-warp">
    <UserLogin v-if="!loginUser.id" v-drag @login="userLogin" />
    <div v-if="loginUser.id&&deviceType==='pc'" v-drag class="app-main-panel ui-clear">
      <div class="app-aside-panel">
        <div class="app-user-avatar">
          <img :src="loginUser.avatarUrl" alt="" :title="loginUser.name" @mousedown.stop>
        </div>
        <ul class="aside-menu-list" @mousedown.stop>
          <li
            v-for="(item,i) in menus"
            :key="i"
            :class="{active:curMenu===item.name}"
            @click="curMenu=item.name"
          >
            <span :class="item.icon" :title="item.title" />
          </li>
        </ul>
      </div>
      <div class="app-container">
        <div v-show="curMenu==='chat'" class="app-container-panel ui-clear">
          <div class="app-user-panel">
            <div class="app-user-form">
              <span class="iconfont icon-search app-form-icon" />
              <input v-model="keyword" type="text" placeholder="搜索" class="app-form-element">
            </div>
            <div class="app-users-warp scroll">
              <div @mousedown.stop>
                <UserItem
                  v-for="(item,i) in searchUser(keyword)"
                  :key="i"
                  class="app-user-item"
                  :class="{active:item.id===curSession.id}"
                  :user="item"
                  :num="getUnReadNum(item.id)"
                  :message="getSessionLatestMsg(item.id)"
                  @click.native="changeSession(item)"
                >
                  <template v-if="getSessionLatestMsg(item.id).time" slot="time">
                    {{ getSessionLatestMsg(item.id).time | friendlyTime }}
                  </template>
                </UserItem>
              </div>
            </div>
          </div>
          <div class="app-session-panel">
            <UiSessionPanel
              v-if="curSession.id"
              :session="curSession"
              @sendMessage="sendMessage"
            >
              <template slot="info">
                <span v-if="curSession.type==='group'" class="app-user-num">
                  ({{ users.length }})
                </span>
                <span v-if="curSession.type==='user'" class="app-use-extInfo">
                  <i class="iconfont" :class="curSession.deviceType==='pc'?'icon-pc':'icon-phone'" />
                  <span>({{ curSession.ip }})</span>
                </span>
              </template>
              <div slot="body" ref="message-list" class="message-list-warp scroll">
                <UiChatBubble
                  v-for="(item,i) in getMessages(curSession.id)"
                  :key="i"
                  class="message-item"
                  :message="item"
                  :setting="setting"
                  :is-send="loginUser.id===item.from.id"
                />
              </div>
            </UiSessionPanel>
            <div v-else class="app-no-session">
              <span class="iconfont icon-wechat" />
            </div>
          </div>
        </div>
        <div v-show="curMenu==='setting'" class="app-container-panel">
          <div class="app-card-panel">
            <div class="app-card-title">设置</div>
            <div class="app-user-card  ui-clear" @mousedown.stop>
              <div class="app-card-avatar">
                <img :src="loginUser.avatarUrl" alt="">
              </div>
              <div class="app-card-container">
                <div class="app-card-infoRow">{{ loginUser.name }}</div>
                <div class="app-card-infoRow">
                  <i class="iconfont" :class="loginUser.deviceType==='pc'?'icon-pc':'icon-phone'" />
                  <span class="app-login-ip">{{ loginUser.ip }}</span>
                </div>
                <div class="app-card-infoRow">
                  <span class="app-login-time">{{ loginUser.loginTime | formatTime }}</span>
                </div>
              </div>
            </div>
            <ul class="ui-list app-setting" @mousedown.stop>
              <li>
                <span class="ui-label">消息声音</span>
                <UiSwitch v-model="setting.isVoice" class="ui-right" />
              </li>
              <li>
                <span class="ui-label">显示昵称</span>
                <UiSwitch v-model="setting.isName" class="ui-right" />
              </li>
              <li>
                <span class="ui-label">消息时间</span>
                <UiSwitch v-model="setting.isTime" class="ui-right" />
              </li>
            </ul>
          </div>
        </div>
        <div v-show="curMenu==='about'" class="app-container-panel">
          <div class="app-card-panel">
            <div class="app-card-title">关于</div>
            <ul class="ui-list app-setting" @mousedown.stop>
              <li>
                <span class="ui-label">版本：</span>
                <span class="ui-text">{{ about.version }}</span>
              </li>
              <li>
                <span class="ui-label">协议：</span>
                <span class="ui-text">{{ about.license }}</span>
              </li>
              <li>
                <span class="ui-label">作者：</span>
                <span class="ui-text">{{ about.author }}</span>
              </li>
              <li>
                <span class="ui-label">邮箱：</span>
                <span class="ui-text">{{ about.email }}</span>
              </li>
              <li>
                <span class="ui-label">仓库：</span>
                <a class="ui-link" :href="about.github" target="_blank">GitHub</a>
              </li>
              <li>
                <a class="ui-link" :href="about.github" target="_blank">
                  <img src="https://img.shields.io/github/stars/cleverqin/node-websocket-Chatroom?label=Star&style=flat&logo=github" alt="">
                </a>
                <a class="ui-link" :href="about.github" target="_blank">
                  <img src="https://img.shields.io/github/forks/cleverqin/node-websocket-Chatroom?label=Fork&style=flat&logo=github" alt="">
                </a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div v-if="loginUser.id&&deviceType==='phone'" class="app-main-touch">
      <div class="app-iChat-container">
        <div v-show="curMenu==='chat'" class="app-iChat-panel">
          <div class="iChat-search-warp">
            <div class="iChat-user-avatar">
              <img :src="loginUser.avatarUrl" alt="">
            </div>
            <div class="iChat-element">
              <span class="iconfont icon-search" />
              <input v-model="keyword" type="text" class="iChat-search-input" placeholder="搜索">
            </div>
          </div>
          <div class="iChat-users-warp">
            <UserItem
              v-for="(item,i) in searchUser(keyword)"
              :key="i"
              class="iChat-user-item"
              :class="{active:item.id===curSession.id}"
              :user="item"
              :num="getUnReadNum(item.id)"
              :message="getSessionLatestMsg(item.id)"
              @click.native="changeSession(item)"
            >
              <template v-if="getSessionLatestMsg(item.id).time" slot="time">
                {{ getSessionLatestMsg(item.id).time | friendlyTime }}
              </template>
            </UserItem>
          </div>
        </div>
        <div v-show="curMenu==='setting'" class="app-iChat-panel">
          <div class="iChat-setting-cover">
            <img :src="loginUser.avatarUrl" alt="">
          </div>
          <ul class="ui-list app-setting" @mousedown.stop>
            <li>
              <span class="ui-label">用户名</span>
              <span class="ui-right">{{ loginUser.name }}</span>
            </li>
            <li>
              <span class="ui-label">登录时间</span>
              <span class="ui-right">{{ loginUser.loginTime | formatTime }}</span>
            </li>
            <li>
              <span class="ui-label">IP</span>
              <span class="ui-right">{{ loginUser.ip }}</span>
            </li>
            <li>
              <span class="ui-label">设备</span>
              <span class="ui-right">
                <i class="iconfont" :class="loginUser.deviceType==='pc'?'icon-pc':'icon-phone'" />
              </span>
            </li>
            <li>
              <span class="ui-label">消息声音</span>
              <UiSwitch v-model="setting.isVoice" class="ui-right" />
            </li>
            <li>
              <span class="ui-label">显示昵称</span>
              <UiSwitch v-model="setting.isName" class="ui-right" />
            </li>
            <li>
              <span class="ui-label">消息时间</span>
              <UiSwitch v-model="setting.isTime" class="ui-right" />
            </li>
          </ul>
        </div>
        <div v-show="curMenu==='about'" class="app-iChat-panel">
          <div class="app-card-title">关于</div>
          <ul class="ui-list app-setting">
            <li>
              <span class="ui-label">版本：</span>
              <span class="ui-text">{{ about.version }}</span>
            </li>
            <li>
              <span class="ui-label">协议：</span>
              <span class="ui-text">{{ about.license }}</span>
            </li>
            <li>
              <span class="ui-label">作者：</span>
              <span class="ui-text">{{ about.author }}</span>
            </li>
            <li>
              <span class="ui-label">邮箱：</span>
              <span class="ui-text">{{ about.email }}</span>
            </li>
            <li>
              <span class="ui-label">仓库：</span>
              <a class="ui-link" :href="about.github" target="_blank">GitHub</a>
            </li>
            <li>
              <a class="ui-link" :href="about.github" target="_blank">
                <img src="https://img.shields.io/github/stars/cleverqin/node-websocket-Chatroom?label=Star&style=flat&logo=github" alt="">
              </a>
              <a class="ui-link" :href="about.github" target="_blank">
                <img src="https://img.shields.io/github/forks/cleverqin/node-websocket-Chatroom?label=Fork&style=flat&logo=github" alt="">
              </a>
            </li>
          </ul>
        </div>
      </div>
      <div class="app-iChat-footer">
        <ul class="app-iChat-menus ui-clear">
          <li
            v-for="(item,i) in menus"
            :key="i"
            class="iChat-menu-item"
            :class="{active:curMenu===item.name}"
            @click="curMenu=item.name"
          >
            <div class="iChat-menu-icon">
              <span :class="item.icon" />
            </div>
            <div class="iChat-menu-name">{{ item.title }}</div>
          </li>
        </ul>
      </div>
      <SessionPanel v-show="curSession.id" :session="curSession" @back="changeSession({})" @sendMessage="sendMessage">
        <template slot="num">
          ({{ users.length }})
        </template>
        <div ref="message-list" class="iChat-message-warp">
          <div class="iChat-message-list">
            <UiChatBubble
              v-for="(item,i) in getMessages(curSession.id)"
              :key="i"
              class="message-item"
              :message="item"
              :setting="setting"
              :is-send="loginUser.id===item.from.id"
            />
          </div>
        </div>
      </SessionPanel>
    </div>
    <audio ref="audio" :src="audioSrc" />
  </div>
</template>

<script>
import UserItem from '../components/UserItem'
import UiSessionPanel from '../components/UiSessionPanel'
import UiChatBubble from '../components/UiChatBubble'
import UiSwitch from '../../../components/UiSwitch'
import UserLogin from '../components/UserLogin'
import SessionPanel from '../components/SessionPanel'
import { getDeviceType } from '../../../components/emoji'
export default {
  name: 'UiChatApp',
  components: {
    UserItem,
    UiSessionPanel,
    UiChatBubble,
    UiSwitch,
    UserLogin,
    SessionPanel
  },
  filters: {
    friendlyTime(value) {
      let time = new Date().getTime()
      time = parseInt((time - value) / 1000)
      // 存储转换值
      let s
      if (time < 60 * 3) { // 三分钟内
        return '刚刚'
      } else if ((time < 60 * 60) && (time >= 60 * 3)) {
        // 超过十分钟少于1小时
        s = Math.floor(time / 60)
        return s + '分钟前'
      } else if ((time < 60 * 60 * 24) && (time >= 60 * 60)) {
        // 超过1小时少于24小时
        s = Math.floor(time / 60 / 60)
        return s + '小时前'
      } else if ((time < 60 * 60 * 24 * 3) && (time >= 60 * 60 * 24)) {
        // 超过1天少于3天内
        s = Math.floor(time / 60 / 60 / 24)
        return s + '天前'
      } else {
        // 超过3天
        const date = new Date(value)
        return date.getFullYear() + '.' + (date.getMonth() + 1) + '.' + date.getDate()
      }
    },
    formatTime(value) {
      const date = new Date(value)
      const year = date.getFullYear()
      const month = date.getMonth() + 1
      const day = date.getDate()
      const hour = date.getHours() > 9 ? date.getHours() : ('0' + date.getHours())
      const minutes = date.getMinutes() > 9 ? date.getMinutes() : ('0' + date.getMinutes())
      const seconds = date.getSeconds() > 9 ? date.getSeconds() : ('0' + date.getSeconds())
      return year + '.' + month + '.' + day + ' ' + hour + ':' + minutes + ':' + seconds
    }
  },
  data() {
    const type = getDeviceType(window.navigator.userAgent)
    return {
      menus: [
        {
          name: 'chat',
          icon: 'iconfont icon-comments',
          title: '会话'
        },
        {
          name: 'setting',
          icon: 'iconfont icon-cog',
          title: '设置'
        },
        {
          name: 'about',
          icon: 'iconfont icon-info',
          title: '关于'
        }
      ],
      curMenu: 'chat',
      users: [
        {
          id: 'group_001',
          name: '聊天室',
          avatarUrl: 'static/images/avatar/group-icon.png',
          type: 'group'
        },
        {
          id: 'user_002',
          name: '耍猴大神',
          avatarUrl: 'http://q.qlogo.cn/headimg_dl?dst_uin=240571231&spec=100',
          deviceType: 'pc',
          type: 'user',
          time: new Date().getTime(),
          ip: '102.33.234.231'
        },
        {
          id: 'user_003',
          name: '史蒂夫',
          avatarUrl: 'http://q.qlogo.cn/headimg_dl?dst_uin=33685432&spec=100',
          deviceType: 'phone',
          type: 'user',
          time: new Date().getTime(),
          ip: '102.33.24.231'
        }
      ],
      curSession: {},
      keyword: '',
      messageData: {},
      setting: {
        isName: true,
        isTime: true,
        isVoice: true
      },
      about: {
        version: 'v1.0',
        license: 'MIT',
        author: 'cleverqin',
        email: '705597001@qq.com',
        github: 'https://github.com/cleverqin/node-websocket-Chatroom'
      },
      loginUser: {},
      deviceType: type,
      audioSrc: './static/8400.mp3'
    }
  },
  methods: {
    searchUser(keyword) {
      const arr = []
      this.users.forEach((item) => {
        if ((item.name.indexOf(keyword) !== -1) || (item.id.indexOf(keyword) !== -1)) {
          arr.push(item)
        }
      })
      return arr
    },
    getMessages(sessionId) {
      if (sessionId && this.messageData[sessionId]) {
        return this.messageData[sessionId]
      }
      return []
    },
    addSessionMessage(message, sessionId) {
      const vm = this
      if (!this.messageData[sessionId]) {
        this.$set(this.messageData, sessionId, [])
      }
      this.messageData[sessionId].push(message)
      if (this.curSession.id === sessionId) {
        setTimeout(() => {
          vm.scrollFooter('message-list')
        }, 16)
      }
      if (this.setting.isVoice && this.loginUser.id !== message.from.id) {
        this.playAudio()
      }
    },
    sendMessage(content, type, session) {
      const message = {
        from: this.loginUser,
        to: session,
        content: content,
        type: type,
        time: new Date().getTime(),
        isRead: true
      }
      this.addSessionMessage(message, session.id)
      const temps = [
        '我没听明白你在说什么？',
        '有趣的问题。',
        '我只想说，我什么都不会',
        '[微笑]，今天是——————？'
      ]
      const len = temps.length
      const index = parseInt(Math.random() * len)
      const reply = {
        from: session,
        to: this.loginUser,
        content: temps[index],
        type: 'text',
        time: new Date().getTime(),
        isRead: false
      }
      this.addSessionMessage(reply, session.id)
    },
    getSessionLatestMsg(sessionId) {
      const messages = this.getMessages(sessionId)
      if (messages.length > 0) {
        return messages[messages.length - 1]
      }
      return {}
    },
    getUnReadNum(sessionId) {
      let num = 0
      const messages = this.getMessages(sessionId)
      if (messages.length === 0) {
        return num
      }
      messages.forEach((item) => {
        if (!item.isRead) {
          num++
        }
      })
      return num
    },
    setSessionRead(sessionId) {
      const messages = this.getMessages(sessionId)
      if (messages.length === 0) {
        return
      }
      messages.forEach((item) => {
        if (!item.isRead) {
          item.isRead = true
        }
      })
    },
    scrollFooter(name) {
      const $el = this.$refs[name]
      if ($el) {
        this.$nextTick(() => {
          $el.scrollTop = $el.scrollHeight
        })
      }
    },
    changeSession(session) {
      const vm = this
      if (session.id === this.curSession.id) {
        return
      }
      this.setSessionRead(session.id)
      this.curSession = session
      setTimeout(() => {
        vm.scrollFooter('message-list')
      }, 16)
    },
    userLogin(value) {
      const user = Object.assign({}, value)
      user.id = 'user_0001'
      user.type = 'user'
      user.deviceType = 'pc'
      user.ip = '10.23.123.22'
      user.loginTime = new Date().getTime()
      this.loginUser = user
    },
    playAudio() {
      const $audio = this.$refs['audio']
      if ($audio) {
        $audio.play()
      }
    }
  }
}
</script>

<style scoped lang="less">
  .chat-app-warp{
    width: 100%;
    height: 100%;
    position: relative;
    background-image: url("https://cn.bing.com/th?id=OHR.LeMorneBrabant_ZH-CN9699020288_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
  }
  .ui-clear:after{
    display: block;
    content: '';
    clear: both;
  }
  .app-main-panel{
    width: 700px;
    height: 600px;
    background-color: #f2f2f2;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -350px;
    margin-top: -300px;
  }
  .app-aside-panel{
    width: 60px;
    position: relative;
    height: 100%;
    float: left;
    background-color: #333333;
  }
  .app-user-avatar{
    padding: 10px;
  }
  .app-user-avatar img{
    width:40px;
    height: 40px;
    border-radius: 4px;
  }
  .aside-menu-list{
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .aside-menu-list li{
    line-height: 40px;
    height: 40px;
    text-align: center;
    cursor: pointer;
  }
  .aside-menu-list li span{
    font-size: 22px;
    color: #f2f2f2;
  }
  .aside-menu-list li:hover span,
  .aside-menu-list li.active span{
    color: #b2e281;
  }
  .app-container{
    height: 100%;
    margin-left:60px;
  }
  .app-container-panel{
    position: relative;
    width: 100%;
    height: 100%;
  }
  .app-user-panel{
    width: 220px;
    height: 100%;
    position: relative;
    border-right: 1px solid #d1d1d1;
    background-color: #fcfcfc;
    box-sizing: border-box;
    float: left;
  }
  .app-users-warp{
    height: calc(100% - 60px);
    overflow-y: auto;
  }
  .app-user-item{
    cursor: pointer;
  }
  .app-user-item:hover{
    background-color: #f2f2f2;
  }
  .app-user-item.active{
    background-color: #ededed;
  }
  .app-session-panel{
    margin-left: 220px;
    height: 100%;
  }
  .app-warp{
    margin: 0 auto;
  }
  .message-list-warp{
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    overflow-y: auto;
  }
  .message-item:first-child{
    margin-top: 0;
  }
  .message-item{
    margin-top: 10px;
  }
  .app-user-form{
    height: 50px;
    box-sizing: border-box;
    padding: 10px;
    position: relative;
  }
  .app-form-icon{
    position: absolute;
    top: 10px;
    font-size: 18px;
    margin-left: 5px;
    height: 30px;
    color: #606266;
    line-height: 30px;
  }
  .app-form-element{
    height: 30px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px 8px 25px;
    border-radius: 15px;
    outline: none;
    border: none;
    background-color: #ebeef0;
    color: #666666;
  }
  .app-no-session{
    position: relative;
    width: 100%;
    height: 100%;
  }
  .app-no-session span.iconfont{
    position: absolute;
    display: block;
    width: 100px;
    height: 100px;
    top: 50%;
    left: 50%;
    text-align: center;
    line-height: 100px;
    vertical-align: middle;
    margin-top: -50px;
    margin-left: -50px;
    font-size: 100px;
    color: #e7e7e7;
  }
  .app-user-num{
    font-size: 12px;
    color: #666666;
  }
  .app-use-extInfo i.iconfont{
    display: inline-block;
    font-size: 18px;
    color: #0e8307;
    line-height: 30px;
    margin-right: 5px;
    position: relative;
    top: 2px;
  }
  .app-use-extInfo span{
    font-size: 12px;
    color: #666666;
  }
  .app-card-title{
    font-size: 16px;
    line-height: 40px;
    color: #333333;
    padding: 0 10px;
  }
  .app-user-card{
    padding: 10px;
    height: 60px;
  }
  .app-card-avatar{
    float: left;
    width: 60px;
    height: 60px;
    border-radius: 4px;
  }
  .app-card-avatar img{
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 4px;
  }
  .app-card-container{
    margin-left: 70px;
    height: 60px;
  }
  .app-card-infoRow{
    line-height: 20px;
    height: 20px;
  }
  .app-card-infoRow i.iconfont{
    font-size: 16px;
    color: #0e8307;
  }
  .app-login-ip{
    font-size: 14px;
    color: #666666;
    margin-left: 5px;
  }
  .app-login-time{
    font-size: 14px;
    color: #666666;
  }
  .app-setting{
    max-width: 400px;
  }
  .ui-list{
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .ui-list li{
    line-height: 20px;
    height: 40px;
    border-bottom: 1px solid #d9dce0;
    padding: 10px;
    margin: 0 10px;
    box-sizing: border-box;
  }
  .ui-list li .ui-label{
    font-size: 14px;
    color: #333333;
  }
  .ui-right{
    float: right;
  }
  .ui-text{
    font-size: 14px;
    color: #666666;
  }
  .ui-link{
    font-size: 14px;
    color: #4792ff;
    text-decoration: none;
    margin-right: 5px;
  }
  /*定义滚动条宽高及背景，宽高分别对应横竖滚动条的尺寸*/
  .scroll::-webkit-scrollbar{
    width: 5px;
    height: 5px;
    background-color: rgba(255, 255, 255, 0.13);
  }
  /*定义滚动条的轨道，内阴影及圆角*/
  .scroll::-webkit-scrollbar-track{
    -webkit-box-shadow: inset 0 0 6px rgba(240, 240, 240, 0);
    border-radius: 10px;
    background-color: rgba(0, 89, 255, 0);
  }
  /*定义滑块，内阴影及圆角*/
  .scroll::-webkit-scrollbar-thumb{
    /*width: 10px;*/
    height: 20px;
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(236, 236, 236, 0.3);
    background-color: rgba(203, 203, 203, 0.54);
    transition: all 0.5s;
  }
</style>
<style scoped lang="less">
  .app-main-touch{
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #ffffff;
  }
  .app-iChat-container{
    height: calc(100% - 61px);
    width: 100%;
    position: relative;
  }
  .app-iChat-menus{
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #ffffff;
    border-top: 1px solid #d1d1d1;
  }
  .iChat-menu-item{
    float: left;
    width: 33.3333333%;
    text-align: center;
    color: #666666;
    height: 60px;
    padding: 6px 0;
    box-sizing: border-box;
  }
  .iChat-menu-item.active{
    color: #3a8ee6;
  }
  .iChat-menu-icon span.iconfont{
    font-size: 25px;
  }
  .iChat-menu-name{
    font-size: 14px;
  }
  .app-iChat-panel{
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
  }
  .iChat-search-warp{
    height: 60px;
    background-color: #3a8ee6;
    padding: 10px;
    box-sizing: border-box;
  }
  .iChat-user-avatar{
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    float: left;
  }
  .iChat-user-avatar img{
    display: block;
    width: 100%;
    height: 100%;
    border-radius:50px;
  }
  .iChat-element{
    margin-left: 50px;
    position: relative;
  }
  .iChat-element span.iconfont{
    display: block;
    position: absolute;
    left: 0;
    font-size: 16px;
    line-height: 40px;
    height: 40px;
    width: 30px;
    text-align: center;
    color: #ddd;
  }
  .iChat-search-input{
    display: block;
    width: 100%;
    line-height: 20px;
    padding: 10px 10px 10px 30px;
    height: 40px;
    outline: none;
    font-size: 14px;
    color: #f2f2f2;
    box-sizing: border-box;
    border-radius: 4px;
    border: none;
    background: rgba(0,0,0,.11);
  }
  .iChat-search-input::-webkit-input-placeholder{
    color: #ddd;
  }
  .iChat-users-warp{
    height: calc(100% - 60px);
    width: 100%;
    overflow-y: auto;
  }
  .iChat-user-item{
    border-bottom: 1px solid #f2f2f2;
  }
  .iChat-setting-cover{
    height: 160px;
    position: relative;
    background-image: url("https://cn.bing.com/th?id=OHR.LeMorneBrabant_ZH-CN9699020288_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
  }
  .iChat-setting-cover img{
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: absolute;
    border: 4px solid #ffffff;
    left: 50%;
    margin-left: -40px;
    bottom: 0;
    margin-bottom: -20px;
    box-sizing: border-box;
  }
  .app-iChat-panel .app-setting{
    width: 100%;
    max-width: 100%;
  }
  .app-iChat-panel .ui-right{
    font-size: 14px;
    color: #666666;
  }
  .app-iChat-panel .ui-right i.iconfont{
    color: #097603;
  }
  .iChat-message-warp{
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
  }
  .iChat-message-list{
    padding: 10px;
  }
</style>
